<style>
  .content-img {
    width: 250px;
    height: 180px;
  }
  .content > ul {
    list-style: none;
    float: left;
    margin-left: 60px;
    margin-bottom: 40px;
    height: 310px;
  }
  .content {
    width: 100%;
    height: 100%;
    margin: 0 auto;
  }
  .ul-font > li > span {
    font-size: 14px;
    font-weight: bold;
  }
  .ul-font > li > span:first-child {
    margin-right: 10px;
  }
  .ul-font > li:not(:last-child) > span:last-child {
    display: block;
    margin-left: 80px;
    margin-top: -20px;
  }
  .ul-font > li:last-child > span:last-child {
    margin-left: 25px;
  }
  .ul-font {
    width: 230px;
    margin-top: 20px;
    margin-left: 15px;
  }
</style>
<template>
  <div class="content">
    <ul v-for="(item, index) in list" :key="index">
      <li>
        <a @click="handleClick(index, item)">
          <img :src="item.img ? item.host+item.img : ''" alt="" class="content-img">
        </a>
      </li>
      <div class="ul-font">
        <li>
          <span>创建时间：</span>
          <span>{{item.ctime}}</span>
        </li>
        <li>
          <span>内容标题：</span>
          <span :title="item.name">{{item.name && item.name.length > 8 ? item.name.slice(0, 8) + '...' : item.name ? item.name : '-'}}</span>
        </li>
        <li>
          <span>副标题：</span>
          <span :title="item.subtitle">{{item.subtitle && item.subtitle.length > 8 ? item.subtitle.slice(0, 8) + '...' : item.subtitle ? item.subtitle : '-'}}</span>
        </li>
        <li>
          <span>修改时间：</span>
          <span>{{item.uptime}}</span>
        </li>
        <li>
          <span>操作：</span>
          <span>
            <Button @click="handleEdit(item)" type="primary" size="small" ghost style="margin-right: 5px">编辑</Button>
          </span>
        </li>
      </div>
    </ul>
    <div style="clear: both"></div>
  </div>
</template>
<script>
import {
  mapState,
  mapActions,
  mapMutations
} from 'vuex'
import qqgroup from '@/assets/images/qq-group1.jpg'
export default {
  name: 'ContentList',
  props: {
    list: null,
    index: ''
  },
  data () {
    return {
      data: []
    }
  },
  methods: {
    handleClick (index, item) {
      this.$emit('view-content', index, item)
    },
    handleEdit (item) {
      this.$emit('edit-content', item)
    },
    handleDelete (index) {
      this.$emit('delete-content', index)
    }
  }
}
</script>
